<?=$this->header(true, false, true)?>


    <?=$this->menu("forums")?>


    <h1><?=$this->message("label.header", _Forum::BUNDLE)?></h1>


    <? /* Breadcrums route */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.category.header", _Forum::BUNDLE),
                "href"=>"forum/category/list"
            ),
            array(
                "name"=>$this->category($this->topicForm->getTopic()->getCategoryId()),
                "href"=>"forum/list"
            ),
            array(
                "name"=>($this->topicForm->getTopic()->getTopicId() > 0 ?
                    $this->message("route.edit", _Core::BUNDLE) . " " .
                        "\"".$this->topicForm->getTopic()->getName()."\" " :
                    $this->message("route.new", _Core::BUNDLE) . " " . $this->message("label.item", _Forum::BUNDLE))
            )
        )
    )?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Forum::BUNDLE)?>


    <form id="<?=get_class($this->topicForm)?>" action="forum/save" method="post">

        <div>
            <input type="hidden"
                   name="topic->topicId"
                   value="<?=$this->topicForm->getTopic()->getTopicId()?>" />
            <input type="hidden"
                   name="topic->topic->categoryId"
                   value="<?=$this->topicForm->getTopic()->getCategoryId()?>" />
        </div>

        <fieldset>

            <legend><?=$this->message("label.required")?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("topic->topic->name")?>">
                <th><label for="topic_name"><?=$this->message("prompt.name", _Forum::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="topic->name"
                           id="topic_name"
                           value="<?=$this->topicForm->getTopic()->getName()?>"
                           maxlength="255"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("topic->body")?>">
                <th><label for="topic_body"><?=$this->message("prompt.body", _Forum::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <textarea id="topic_body" name="topic->body" mce_editable="true" rows="20" cols="80"><?=!is_null($this->topicForm->getTopic()->getBody()) ?
                        htmlspecialchars($this->topicForm->getTopic()->getBody()->getContents()) : ""?></textarea>
                </td>
            </tr>
            </table>

        </fieldset>

        <div class="buttons">

            <input type="button"
                   onclick="to('topic/list')"
                   value="<?=$this->message("button.cancel", _Core::BUNDLE)?>"
                   class="button" />
            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>

    </form>

<?=$this->footer()?>